package leetcode;

import java.util.Scanner;

public class code167 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = scanner.nextInt();
        }
        int i = scanner.nextInt();
        int[] ints = twoSum(nums, i);
        System.out.println(ints);

    }

    public static int[] twoSum(int[] numbers, int target) {
        int[] res = new int[2];
        if (numbers.length <=1)
            return res;
        int right = numbers.length-1;
        int left = 0;
        while (right> left){
            int sum = numbers[right] + numbers[left];
            if (sum == target)
                return new int[]{left+1,right+1};
            else if (sum>target) {
                right--;
            }else {
                left++;
            }
        }
        return new int[]{-1,-1};
    }
}
